package demo.compoment;

import demo.enity.User;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

/*@Component*/
public class UserCompoment {
    @Bean("test")//默认作用域是单例的
    //方式一：直接写
    /*@Scope("prototype")*/
    //方式二，用人家提供的参数
    @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
    public User test() {
        User user = new User();
        user.setId(1);
        user.setName("张三");
        return user;
    }
}
